package code.refactoring.View;

import java.util.InputMismatchException;
import java.util.Scanner;

public class AskUser {
	static Scanner sc = new Scanner(System.in);

	public static int askUserForBoardSize() {
		int size = 0;
		boolean isValidInput = false;
		while (isValidInput == false) {
			try {
				System.out.println("Enter size for the gameboard(must "
						+ "be a positive number greater than 1).");
				size = sc.nextInt();
				isValidInput = true;
			} catch (InputMismatchException e) {
				System.out.println("Invalid input,must be a number !");
				sc.nextLine();
			}
		}
		return size;
	}

	/**
	 * Sets Name of the Player
	 * 
	 * @return string value representing the Name of the player
	 */

	public static String askUserForName() {
		String name;
		System.out.print("Enter your nickname: ");
		name = sc.nextLine();
		return name;
	}

	/**
	 * Ask player for his mark. Make sure his mark is an Alphabetical Letter
	 * 
	 * @return symbol (char) which represents players mark
	 */
	public static char askUserForMark() {
		char mark = '\u0000';
		System.out.print("Enter your mark:");
		mark = sc.nextLine().toUpperCase().charAt(0);
		return mark;
	}

	public static int askUserForRow() {
		System.out.print("Please select a row: ");
		return sc.nextInt();
	}

	public static int askUserForColumn() {
		System.out.print("Please select a column: ");
		return sc.nextInt();
	}

	public static char askUserForDirection() {
		System.out.print("Please select the direction of your line: ");
		return sc.next().charAt(0);
	}

}
